# coding=utf-8


"""This is a wrapper for cell requests"""

from pypalo.basic import response, url, default, arguments

request_group="cell"

def area(area, show_rule, show_lock_info, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/area[?PARAMETER1=value[&...]].
	
	Short description: 
	
	Long description: 
	
	Parameters:
		database [identifier] <Identifier of the database>
		cube [identifier] <Identifier of a cube>
		area [area] <Comma separated list of element identifiers list. Each element identifiers list is colon separated. The area is the cartesian product.>
		show_rule [boolean] <If 1, then additional information about the cell value is returned, in case the value originates from an enterprise rule.>
		show_lock_info [boolean] <If 1, then additional information about the cell lock is returned.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 type [integer] <Type of the value (1=NUMERIC, 2=STRING)>
		1 exists [boolean] <1 if at least base cell for the path exists>
		2 value [double/string] <Value of the cell>
		3 path [path] <Comma separate list of element identifier (path of cube cell)>
		4 rule [identifier] <Identifier of the rule, this cell values originates from or empty. Only available if show_rule is 1.>
		5 lock_info [identifier] <Lock info (0 - cell is not locked, 1 - cell is locked by user wich sent request, 2 - cell is locked by another user). Only available if show_lock_info is 1.>
	
	More info at http://host:port/api/cell/area
	'''
	#beginning of function suite
	request_name="area"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def copy(path_to, path, cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/copy[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of the database>
		cube [identifier] <Identifier of a cube>
		path [path] <Source cell path. Comma separate list of element identifier.>
		path_to [path] <Target cell path. Comma separate list of element identifier.>
		value [double] <The numeric value of the target cube cell. (optional)>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
		
	More info at http://host:port/api/cell/copy
	'''
	#beginning of function suite
	request_name="copy"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def drillthrough(mode, path, cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/drillthrough[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of the database>
		cube [identifier] <Identifier of a cube>
		path [path] <Comma separate list of element identifier (path of cube cell)>
		mode [integer] <1 - History, 2 - Details,..., n - User defined>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 resultset [string] <Comma separated component-values (columns) of resultset; First row: Component names of resultset-columns>
	
	More info at http://host:port/api/cell/drillthrough
	'''
	#beginning of function suite
	request_name="drillthrough"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def export(cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/export[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of the database>
		cube [identifier] <Identifier of a cube>
		blocksize [integer] <Maximal number of cells to export (default is 1000)>
		path [path] <Begin export after the path (default is to start with first path)>
		area [area] <Comma separated list of element identifiers list. Each element identifiers list is colon separated. The area is the cartesian product. Default is the complete cube area.>
		condition [string] <Condition on the value of numeric or string cells (default is no condition). A condition starts with >, >=, <, <=, ==, or != and is followed by a double or a string. Two condition can be combined by and, or, xor. If you specifiy a string value, the value has to be csv encoded. Do not forget to URL encode the complete condition string.>
		use_rules [boolean] <If 1, then export rule based cell values (default is 0)>
		base_only [boolean] <If 1, then export only base cells (default is 0)>
		skip_empty [boolean] <If 0, then export empty cells as well (default is 1)>
		type [integer] <Type of exported cells. 0=numeric and string, 1=only numeric, 2=only string (default is 0)>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 type [integer] <Type of the value (1=NUMERIC, 2=STRING)>
		1 exists [boolean] <1 if at least base cell for the path exists>
		2 value [double/string] <Value of the cell>
		3 path [path] Comma separate list of element identifier (path of cube cell)
	
	More info at http://host:port/api/cell/export
	'''
	#beginning of function suite
	request_name="export"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def goalseek(path, cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/goalseek[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		path [path] <Target cell path. Comma separate list of element identifier.>
		value [double] <The numeric value of the target cube cell. (optional)>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/cell/goalseek
	'''
	#beginning of function suite
	request_name="goalseek"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def replace(value, path, cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/replace[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		path [path] <Comma separate list of element identifier.>
		value [double/string] <The numeric or string value of the cube cell. Do not forget to URL encode string values.>
		add [boolean] <If 0 (the default), then a numeric value given is stored in the cube. If 1, then a numeric value given is added to the existing value or set if no value currently exists. Setting add to 1, requires splash mode 0, 1, or 2.>
		splash [integer] <Optional splash mode for setting values if the comma separated list of elements contains consolidated elements. (0=no splashing, 1=default, 2=add, 3=set)>
		event_processor [boolean] <If 1 (the default), then setting a new value will possibly call the supervision event processor. If 0, then the supervision event processor is circumvented. Note that you need extra permissions to use this feature.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/cell/replace
	'''
	#beginning of function suite
	request_name="replace"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def replace_bulk(paths, values, cube, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/replace_bulk[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		paths [path] <Colon separated list of paths. Each path is comma separate list of element identifier.>
		values [double/string] <Colon separated list of values. Each value is the new numeric or string value for the cell corresponding to the above path. If you specifiy a string value, the value has to be csv encoded.>
		add [boolean] <If 0 (the default), then a numeric value given is stored in the cube. If 1, then a numeric value given is added to the existing value or set if no value currently exists. Setting add to 1, requires splash mode 0, 1, or 2.>
		splash [integer] <Optional splash mode for setting values if the comma separated list of elements contains consolidated elements. (0=no splashing, 1=default, 2=add, 3=set)>
		event_processor [boolean] <If 1 (the default), then setting a new value will possibly call the supervision event processor. If 0, then the supervision event processor is circumvented. Note that you need extra permissions to use this feature.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/cell/replace_bulk
	'''
	#beginning of function suite
	request_name="replace_bulk"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def value(show_rule, show_lock_info, path, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/value[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		path [path] <Comma separate list of element identifier (path of cube cell)>
		show_rule [boolean] <If 1, then additional information about the cell value is returned, in case the value originates from an enterprise rule.>
		show_lock_info [boolean] <If 1, then additional information about the cell lock is returned.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 type [integer] <Type of the value (1=NUMERIC, 2=STRING)>
		1 exists [boolean] <1 if at least one base cell for the path exists>
		2 value [double/string] <Value of the cell>
		3 rule [identifier] <Identifier of the rule, this cell values originates from or empty. Only available if show_rule is 1.>
		4 lock_info [identifier] <Lock info (0 - cell is not locked, 1 - cell is locked by user wich sent request, 2 - cell is locked by another user). Only available if show_lock_info is 1.>
	
	More info at http://host:port/api/cell/value
	'''
	#beginning of function suite
	request_name="value"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def values(paths, show_rule, show_lock_info, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/cell/values[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		paths [path] <Colon separated list of comma separate element identifiers>
		show_rule [boolean] <If 1, then additional information about the cell value is returned, in case the value originates from an enterprise rule.>
		show_lock_info [boolean] <If 1, then additional information about the cell lock is returned.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 type [integer] <Type of the value (1=NUMERIC, 2=STRING, 99=ERROR)>
		1 exists/error [integer] <1 if at least base cell for the path exists. In case of an error the error code.>
		2 value [double/string] <Value of the cell. In case of an error the error message>
		3 rule [identifier] <Identifier of the rule, this cell values originates from or empty. Only available if show_rule is 1.>
		4 lock_info [identifier] <Lock info (0 - cell is not locked, 1 - cell is locked by user wich sent request, 2 - cell is locked by another user). Only available if show_lock_info is 1.>
	
	More info at http://host:port/api/cell/values
	'''
	#beginning of function suite
	request_name="values"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

#query dictionary
query={}
query["area"]=area
query["copy"]=copy
query["drillthrough"]=drillthrough
query["export"]=export
query["goalseek"]=goalseek
query["replace"]=replace
query["replace_bulk"]=replace_bulk
query["value"]=value
query["values"]=values

#end of cell module suite